package net.tavion.angelboot.common.utils;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Map;
import java.util.function.Supplier;

public class JudgeUtils {

    private static final Logger logger = LoggerFactory.getLogger(JudgeUtils.class);
    public static final String successfulMsgCode = "00000";

    public JudgeUtils() {
    }

    public static <T> boolean isNull(T t) {
        return null == t;
    }

    public static <T> boolean isNotNull(T t) {
        return null != t;
    }

    @SafeVarargs
    public static <T> boolean isNullAny(T... ts) {
        if (null == ts) {
            return true;
        } else {
            Object[] var1 = ts;
            int var2 = ts.length;

            for(int var3 = 0; var3 < var2; ++var3) {
                T t =(T) var1[var3];
                if (null == t) {
                    return true;
                }
            }

            return false;
        }
    }

    public static <T, L> boolean equals(T t, L l) {
        return t.equals(l);
    }

    public static <T, L> boolean notEquals(T t, L l) {
        return !equals(t, l);
    }

    public static boolean equals(String str1, String str2) {
        return StringUtils.equals(str1, str2);
    }

    public static boolean equalsIgnoreCase(String str1, String str2) {
        return StringUtils.equalsIgnoreCase(str1, str2);
    }

    public static boolean notEquals(String str1, String str2) {
        return !equals(str1, str2);
    }

    public static boolean equalsAny(String str1, String... strs) {
        if (null == strs && null == str1) {
            return true;
        } else if (null == strs) {
            return false;
        } else {
            boolean f = false;
            String[] var3 = strs;
            int var4 = strs.length;

            for(int var5 = 0; var5 < var4; ++var5) {
                String s = var3[var5];
                if (equals(str1, s)) {
                    f = true;
                    break;
                }
            }

            return f;
        }
    }

    public static boolean isEmpty(String str) {
        return StringUtils.isEmpty(str);
    }

    public static boolean isNotEmpty(String str) {
        return !isEmpty(str);
    }

    public static boolean isBlank(String str) {
        return StringUtils.isBlank(str);
    }

    public static boolean isNotBlank(String str) {
        return !isBlank(str);
    }

    public static boolean isNotBlankAll(String... args) {
        if (null == args) {
            return false;
        } else {
            boolean f = true;
            String[] var2 = args;
            int var3 = args.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                String s = var2[var4];
                if (isBlank(s)) {
                    f = false;
                    break;
                }
            }

            return f;
        }
    }

    public static boolean isBlankAll(String... args) {
        if (null == args) {
            return true;
        } else {
            boolean f = true;
            String[] var2 = args;
            int var3 = args.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                String s = var2[var4];
                if (isNotBlank(s)) {
                    f = false;
                    break;
                }
            }

            return f;
        }
    }

    public static boolean isBlankAny(String... args) {
        if (null == args) {
            return true;
        } else {
            boolean f = false;
            String[] var2 = args;
            int var3 = args.length;

            for(int var4 = 0; var4 < var3; ++var4) {
                String s = var2[var4];
                if (isBlank(s)) {
                    f = true;
                    break;
                }
            }

            return f;
        }
    }

    public static boolean isEmpty(Collection<?> c) {
        if (null == c) {
            return true;
        } else {
            return c.size() <= 0;
        }
    }

    public static boolean isNotEmpty(Collection<?> c) {
        return !isEmpty(c);
    }

    public static boolean isEmpty(Map<?, ?> map) {
        if (null == map) {
            return true;
        } else {
            return map.size() <= 0;
        }
    }

    public static boolean isNotEmpty(Map<?, ?> map) {
        return !isEmpty(map);
    }



    public static <T> boolean isEmpty(T[] ts) {
        if (null == ts) {
            return true;
        } else {
            return ts.length <= 0;
        }
    }

    public static <T> boolean isNotEmpty(T[] ts) {
        return !isEmpty(ts);
    }

    public static boolean contain(String[] args, String s) {
        if (isEmpty((Object[])args)) {
            return false;
        } else {
            boolean f = false;
            String[] var3 = args;
            int var4 = args.length;

            for(int var5 = 0; var5 < var4; ++var5) {
                String a = var3[var5];
                if (equals(a, s)) {
                    f = true;
                    break;
                }
            }

            return f;
        }
    }
    public static boolean not(boolean flag) {
        return !flag;
    }

    public static boolean isTrue(Boolean flag, boolean defaultFlag) {
        return null == flag ? defaultFlag : flag;
    }

    public static <T> T callbackIfNecessary(boolean flag, Supplier<T> supplier) {
        return flag ? supplier.get() : null;
    }


}
